﻿let WebAppEdgeMessageCallbackList = [];
chrome.webview.addEventListener('message', event => {
    for (let i = 0; i < WebAppEdgeMessageCallbackList.length; i++) {
        if (WebAppEdgeMessageCallbackList[i].QueryId === event.data.QueryId) {
            WebAppEdgeMessageCallbackList[i].Callback(event.data.QueryId, event.data.Message);
            WebAppEdgeMessageCallbackList.splice(i, 1);
            break;
        }
    }
});
function WebAppQuery(queryId, message, callback) {
    let msgObj = { QueryId: queryId, Message: message };
    WebAppEdgeMessageCallbackList.push({ QueryId: queryId, Callback: callback });
    chrome.webview.postMessage(msgObj);
}